package com.example.manager.entity;

import java.util.Date;
import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;

import org.springframework.format.annotation.DateTimeFormat;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;

@JsonIgnoreProperties(value = { "hibernateLazyInitializer"})
@Entity
public class Student {
	
	@Id
	@Column(columnDefinition="char(10)")
	private String sid;
	private String name;
	private String password;
	private Gender gender;
	@JsonFormat(pattern="yyyy-MM-dd")
	@DateTimeFormat(pattern="yyyy-MM-dd")
	private Date birthday;
	
	@ManyToMany
	@JoinTable(name="course_selection", 
	joinColumns = @JoinColumn(name="student_sid"), 
	inverseJoinColumns = @JoinColumn(name = "course_teaching_id"))
	private List<CourseTeaching> courseSelection;
	
	public String getSid() {
		return sid;
	}
	public void setSid(String sid) {
		this.sid = sid;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public String getPassword() {
		return password;
	}
	public void setPassword(String password) {
		this.password = password;
	}
	public Gender getGender() {
		return gender;
	}
	public void setGender(Gender gender) {
		this.gender = gender;
	}
	public Date getBirthday() {
		return birthday;
	}
	public void setBirthday(Date birthday) {
		this.birthday = birthday;
	}
	public List<CourseTeaching> getCourseSelection() {
		return courseSelection;
	}
	public void setCourseSelection(List<CourseTeaching> courseSelection) {
		this.courseSelection = courseSelection;
	}

}
